<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset(getThemeAssets('dataTables/datatables.min.css', true))); ?>" rel="stylesheet">
<link href="<?php echo e(asset(getThemeAssets('css/coring.css'))); ?>" rel="stylesheet">
<link href="<?php echo e(asset(getThemeAssets('css/toastr.min.css'))); ?>" rel="stylesheet">
<style type="text/css">
	.col-lg-3{
        margin-left: 0px;
        margin-right: 0px;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="row wrapper border-bottom white-bg page-heading">
  <div class="col-lg-10">
    <h2><?php echo trans('coring.title'); ?></h2>
    <ol class="breadcrumb">
        <li>
            <a href="<?php echo e(url('admin')); ?>"><?php echo trans('home.title'); ?></a>
        </li>
        <li class="active">
            <strong><?php echo trans('coring.title'); ?></strong>
        </li>
    </ol>
  </div>
  <div class="col-lg-2">
    <div class="title-action">

    </div>
  </div>
</div>
<div class="wrapper wrapper-content animaed" style="padding-bottom: 0px;">
<div class="row">
    <div class="col-lg-12">
        <div class="ibox-title">
          <h5><?php echo trans('alarmsetting.extraplace'); ?></h5>
          <div class="ibox-tools">
            <a class="collapse-link">
              <i class="fa fa-chevron-up"></i>
            </a>
            <a class="close-link">
                <i class="fa fa-times"></i>
            </a>
          </div>
        </div>
        <div class="ibox-content" style="height:80px;">
                <form class="form-horizontal" role="form">
                            <div class="col-md-4">
                                <label class="col-md-1 control-label" for="Shop">车 间</label>
                                <div class="col-md-11">
                                    <select class="form-control" name="" id="shop">
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <label class="col-md-1 control-label" for="Part">工 段</label>
                                <div class="col-md-11">
                                    <select class="form-control" name="" id="part">
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <label class="col-md-1 control-label" for="Room">电气室</label>
                                <div class="col-md-11">
                                    <select class="form-control" name="" id="room">
                                    </select>
                                </div>
                            </div>
                </form>
        </div>
  </div>
</div>
</div>
<!-- ajax实时测点值信息获取 -->
<div class="wrapper wrapper-content animaed">
  <div class="row">
    <div class="col-lg-12">
        <div class="ibox-title">
          <h5><?php echo trans('coring.alltime_monitor'); ?></h5>
          <div class="ibox-tools">
            <a class="collapse-link">
              <i class="fa fa-chevron-up"></i>
            </a>
            <a class="close-link">
                <i class="fa fa-times"></i>
            </a>
          </div>
        </div>  
        <div class="ibox-content">
            <div class="alert alert-info fade in">
                <button type="button" class="close" data-dismiss="alert">
                    <span aria-hidden="true">&times;</span>
                </button>
                当前电气室所有回路详情。电流温度颜色变红即为报警状态！！3s刷新一次，或者点击手动刷新。
            </div>
            <button onclick="alltimedata()" class="btn btn-primary">点击刷新</button>
            <div class="realtime-box" id="realtime-box">  
            </div>        
        </div>      
    </div>
  </div>
</div>
<!-- 系统所有测点信息 -->
<div class="wrapper wrapper-content animated">
  <div class="row">
    <div class="col-lg-12">
      <div class="ibox">
        <div class="ibox-title">
          <h5><?php echo trans('coring.all_monitor'); ?></h5>
          <div class="ibox-tools">
            <a class="collapse-link">
              <i class="fa fa-chevron-up"></i>
            </a>
            <a class="close-link">
                <i class="fa fa-times"></i>
            </a>
          </div>
        </div>
        <div class="ibox-content">
        <div class="table-responsive">
          <?php echo $__env->make('flash::message', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
          <!-- <?php echo $html->table(['class' => 'table table-striped table-bordered table-hover']); ?> -->            
        </div>

        </div>
      </div>
    </div>
  </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
  <script src="<?php echo e(asset(getThemeAssets('dataTables/datatables.min.js', true))); ?>"></script>
  <script src="<?php echo e(asset(getThemeAssets('layer/layer.js', true))); ?>"></script>
  <script src="<?php echo e(asset(getThemeAssets('js/toastr.min.js'))); ?>"></script>
  <script type="text/javascript">
    $(document).on('click','.destroy_item',function() {
      var _item = $(this);
      var title = "<?php echo e(trans('common.deleteTitle').trans('user.slug')); ?>？";
      layer.confirm(title, {
        btn: ['<?php echo e(trans('common.yes')); ?>', '<?php echo e(trans('common.no')); ?>'],
        icon: 5
      },function(index){
        _item.children('form').submit();
        layer.close(index);
      });
    });
  </script>
    <script>
    $(document).ready(function () {
//        渲染实时监测div
        $(function () {
            // 定时刷新
            setTimeout(function () {
                devicesinfo();
            },
            500);

            setTimeout(function () {
                    alltimedata();
                },
                50);//setTimeout 程序执行后200毫秒执行push，但是仅此一次。
            setInterval(function () {
                    alltimedata();
                },
                3000);
            // 利用ajax动态加载实时监测信息，实现定时及页面局部刷新
            function alltimedata() {
                $.ajaxSetup({
                     headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "<?php echo e(url('/coring/alltimeinfo')); ?>",
                    data: {},
                    method: 'GET',
                    async: true,
                    // 跨域请求时同时发送自身cookie
                    xhrFields: {
                        withCredentials: true
                    },
                    crossDomain: true,
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    },
                    success: function (data) {
                        var finalarr = data;
                        // var finalarr = eval("(" + data + ")");
                        var html = "";
                        $(".realtime-box").html(html);
                        for (var i = 0; i < finalarr.length; i++) {
                            //填充属性
                            var loop_name = finalarr[i].loop_name;
                            var core_id = finalarr[i].core_id;
                            var resi_current = finalarr[i].resi_current;
                            var smoke_status;
                            if(finalarr[i].smoke == 1) {
                                smoke_status = '<p style="color:red;">气体异常!!!</p>';
                            }else {
                                smoke_status = '正常';
                            }
                            var fire_status;
                            if(finalarr[i].fire == 1) {
                                fire_status = '<p style="color:red;">检测到明火!!!</p>';
                            }else{
                                fire_status = '正常';
                            }
                            var near_infrared_status;
                            if(finalarr[i].near_infrared == 1) {
                                near_infrared_status = '<p style="color:red;">检测到明火!!!</p>';
                            }else {
                                near_infrared_status = '正常';
                            }
                            var status = function (status) {
                                switch (status) {
                                    case 0:
                                        return {'statusClass': 'tag-error', 'status': '离线'};
                                    case 1:
                                        return {'statusClass': 'tag-default', 'status': '<p style="color:#6fc323;">在线</p>'};
                                    case 2:
                                        return {'statusClass': 'tag-warning', 'status': '报警'};
                                }
                            };
                            var cable_temp = finalarr[i].cable_temp;
                            var tempure_status = function (status) {
                                if(status == 1) {
                                    return "<p style='color:red;'>" + cable_temp + " ℃ !!!</p><br>";
                                }else{
                                    return "<p style='color:#6fc323;'>" + cable_temp + "℃</p><br>";
                                }
                            }
                            var location = finalarr[i].location;
                            //填充模板
                            html += "<div class='realtime-item'>"
                                + "<div class=\"monitor-tag " + status(finalarr[i].status).statusClass + "\"></div>"
                                + "<div class='monitor-body'>"
                                + "<h4>" + loop_name + "</h4>"
                                + "<div>"
                                + "<label>当前状态：</label>"
                                + "<p>" + status(finalarr[i].status).status + "</p><br>"
                                + "<label>安装位置：</label>"
                                + "<p>" + location + "电气室</p><br>"
                                + "<label>剩余电流：</label>"
                                + "<p style='color:#6fc323'>" + resi_current + "mA</p><br>"                            
                                + "<label>实时温度：</label>"
                                + tempure_status(finalarr[i].is_tempure_alarm)
                                // + "<p>" + cable_temp + "℃</p><br>"      
                                + "<label >火灾烟雾检测：</label>"
                                + "<p  style='color:#6fc323'>" + smoke_status + "</p><br>"
                                + "<label>传统明火检测：</label>"
                                + "<p  style='color:#6fc323'>" + fire_status + "</p><br>"   
                                + "<label>近红外明火检测：</label>"
                                + "<p  style='color:#6fc323'>" + near_infrared_status + "</p><br>"                     
                                + "</div>"
                                + "</div></div>";
                        }
                        $(".realtime-box").html(html)
                    }
                });
            }
                // 利用ajax动态加载当前用户管理河道信息
                function devicesinfo() {
                    $.ajax({
                        url: "<?php echo e(url ('/admin/coring/getmanagerdevices')); ?>",
                        data: {},
                        type: 'get',
                        datatype: 'json',
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                        },
                        success: function (data) {
                            // 对市option进行填充
                            for (var i=0;i<data['shop_all'].length;i++) {
                                $('#shop').append('<option>'+ data['shop_all'][i]+'</option>');
                            }
                            // 对县（区）option进行填充
                            for (var i=0;i<data['part_all'].length;i++) {
                                $('#part').append('<option>'+ data['part_all'][i]+'</option>');
                            }
                            // 对乡(镇)option进行填充
                            for (var i=0;i<data['room_all'].length;i++) {
                                $('#room'
                                    ).append('<option>'+ data['room_all'][i]+'</option>');
                            }
                            setTimeout(function() {
                                toastr.options = {
                                    closeButton: true,
                                    progressBar: true,
                                    showMethod: 'slideDown',
                                    timeOut: 5000
                                };
                                toastr.success('当前登录用户所管辖的位置信息可进行下拉查看</br>下属管理设备数目为：'+data['count']);

                                }, 100);
                            
                        }
                    });
                }
        });
    });
    </script>
  <?php echo $html->scripts(); ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.'.getTheme(), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>